/// \file
/// \brief \b [Internal] Generates and validates checksums
///
/// \note I didn't write this, but took it from http://www.flounder.com/checksum.htm
///

#ifndef __CHECKSUM_H
#define __CHECKSUM_H

#include "RtDefines.h"
/// Generates and validates checksums
class RT_API_EXPORT CheckSum
{

public:
	
 /// Default constructor
	
	CheckSum()
	{
		Clear();
	}
	
	void Clear()
	{
		sum = 0;
		r = 55665;
		c1 = 52845;
		c2 = 22719;
	}
	
	void Add ( DWORD w );
	
	
	void Add ( WORD w );
	
	void Add ( BYTE* b, DWORD length );
	
	void Add ( BYTE b );
	
	DWORD Get ()
	{
		return sum;
	}
	
protected:
	WORD r;
	WORD c1;
	WORD c2;
	DWORD sum;
};

#endif
